package cn.zhoutingrui.pethome.utils;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 获取微信请求地址
 */
@Component
public class getWechatUrl {
    @Value("${WeChat.appid}")
    private String appid;
    @Value("${WeChat.secret}")
    private String secret;
    private String accessToekn="https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code";
    private String userInfo="https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID";

    public String getAccessToekn(String code){
        return accessToekn.replace("APPID",appid).replace("SECRET",secret).replace("CODE",code);
    }

    public String getUserInfo(String accessToken,String openid){
        return userInfo.replace("ACCESS_TOKEN",accessToken).replace("OPENID",openid);
    }
}
